#include <iostream>
using namespace std;

int smallestNumber(int n) {
    int cnt = 1;
    while (n) {
        n /= 2;
        cnt *= 2;
    }
    return cnt - 1;
}
int main() {
    int n;
    cin >> n;
    cout << smallestNumber(n);
    return 0;
}
